package com.ruoyi.web.controller.system;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.file.FileUploadUtils;
import com.ruoyi.common.utils.file.MimeTypeUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.config.ServerConfig;
import com.ruoyi.system.domain.Candidate;
import com.ruoyi.system.domain.Ccompany;
import com.ruoyi.system.domain.SysProject;
import com.ruoyi.system.domain.SysSchool;
import com.ruoyi.system.service.*;
import com.ruoyi.web.controller.file.EducationData;
import com.ruoyi.web.controller.file.JobData;
import com.ruoyi.web.controller.file.JobslinkData;
import com.ruoyi.web.utils.PDFCVUtils;
import com.ruoyi.web.utils.RemoveHtmlCode;
import com.spire.doc.Document;
import com.sushengren.easyword.EasyWord;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.*;

/**
 * 【请填写功能名称】Controller
 * 
 * @author ruoyi
 * @date 2023-11-01
 */
@RestController
@RequestMapping("/system/candidate")
public class CandidateController extends BaseController
{
    @Resource
    private ICandidateService candidateService;

    @Resource
    private ICcompanyService ccompanyService;

    @Resource
    private ISysUserService sysUserService;

    @Resource
    private ISysSchoolService sysSchoolService;

    @Resource
    private ServerConfig serverConfig;

    @Resource
    private CVPDFRead cvpdfRead;

    /**
     * 导入简历
     */
    @PostMapping("/upload")
    public AjaxResult uploadFile(MultipartFile file) throws Exception {
        try
        {
            // 上传文件路径
            String filePath = RuoYiConfig.getUploadPath();
            // 上传并返回新文件名称
            String fileName = FileUploadUtils.upload(filePath, file);
            fileName = fileName.replace("/profile/upload", "");
            // 解析文件
            String cvPath = filePath + fileName;
            Candidate candidate = new Candidate();
            String cvWords = "";
            if (fileName.toLowerCase().contains("pdf")) {
                cvWords = cvpdfRead.getCVWords(cvPath);
            } else {
                Document doc = new Document(cvPath);
                cvWords = doc.getText();
            }
            if (StringUtils.isBlank(cvWords)) {
                return AjaxResult.error("no data");
            }
            String name = PDFCVUtils.getName(cvWords);
            String email = PDFCVUtils.getEmail(cvWords);
            String gender = PDFCVUtils.getGender(cvWords);
            String phone = PDFCVUtils.getPhone(cvWords);
            candidate.setName(name);
            candidate.setPhone1(phone);
            candidate.setEmail1(email);
            candidate.setGender(gender);
            candidate.setOther(PDFCVUtils.getOther(cvWords));
            List<SysSchool> sysSchoolList = PDFCVUtils.getEducation(cvWords);
            candidate.setSchoolList(sysSchoolList);
            List<Ccompany> ccompanyList = PDFCVUtils.getCompany(cvWords);
            candidate.setCcompanyList(ccompanyList);
            return AjaxResult.success(candidate);
        }
        catch (Exception e)
        {
            return AjaxResult.error(e.getMessage());
        }
    }

    /**
     * 导出word文件
     */
    @GetMapping("/download/{id}")
    public AjaxResult download(@PathVariable("id") Long id) throws IOException {

//        if(StringUtils.isBlank(param1) || StringUtils.isBlank(param2)){
//            return;
//        }

        try {
            Candidate candidate = new Candidate();
            candidate.setId(Long.valueOf(id));
            List<Candidate> list = candidateService.selectCandSearchList(candidate);
            if (list != null && list.size() > 0) {
                Calendar calendar = Calendar.getInstance();
                int year = calendar.get(Calendar.YEAR);
                for (int i = 0; i < list.size(); i++) {
                    //计算年龄
                    if (!StringUtils.isBlank(list.get(i).getBirthyear())) {
                        int y = year - Integer.valueOf(list.get(i).getBirthyear()).intValue();
                        list.get(i).setAge(y);
                    }
                    //获取所有的简历，查出对应的公司
                    Ccompany ccompany = new Ccompany();
                    ccompany.setCid(list.get(i).getId());
                    List<Ccompany> ccompanies = ccompanyService.selectCcompanyList(ccompany);
                    list.get(i).setCcompanyList(ccompanies);

                    //获取所有的简历，查出对应的项目
                    SysProject sysProject = new SysProject();
                    sysProject.setCid(list.get(i).getId());
                    List<SysProject> proList =
                            sysProjectService.selectSysProjectList(sysProject);
                    list.get(i).setProList(proList);

                    //查询学校
                    SysSchool sysSchool = new SysSchool();
                    sysSchool.setUserId(list.get(i).getId());
                    List<SysSchool> sysSchoolList = sysSchoolService.selectSysSchoolList(sysSchool);
                    list.get(i).setSchoolList(sysSchoolList);
                    //查出对应的创建者和更新者
                    if (list.get(i).getCreateUserid() != null) {
                        SysUser sysUser = sysUserService.selectUserById(list.get(i).getCreateUserid());
                        if (sysUser != null) {
                            list.get(i).setCreateBy(sysUser.getUserName());
                        }
                    }
                    if (list.get(i).getUpdateUserid() != null) {
                        SysUser sysUser = sysUserService.selectUserById(list.get(i).getUpdateUserid());
                        if (sysUser != null) {
                            list.get(i).setUpdateBy(sysUser.getUserName());
                        }
                    }
                    String filePath = list.get(i).getFilePath();
                    //需要检查的文件格式
                    for (int j = 0; j < MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION.length; j++) {
                        File file = new File("/home/ruoyi/uploadPath/folder/" + "CV" + list.get(i).getId() + "." + MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION[j]);
                        if (file.exists()) {
                            //存在
                            if (StringUtils.isBlank(filePath)) {
                                filePath = "http://jobslink.megaslink.com/profile/folder/" + "CV" + list.get(i).getId() + "." + MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION[j];
                            } else {
                                filePath = filePath + "," + "http://jobslink.megaslink.com/profile/folder/" + "CV" + list.get(i).getId() + "." + MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION[j];
                            }
                        }
                    }
                    list.get(i).setFilePath(filePath);
                }
                Candidate candidate1 = list.get(0);
                //设置浏览器导出excl格式文件
                //response.setContentType("application/vnd.openxmlformats-officedocument.wordprocessingml.sheet");
                //设置浏览器导出word格式文件
//                response.setContentType("application/vnd.openxmlformats-officedocument.wordprocessingml.document");
//                //设置字符集
//                response.setCharacterEncoding("utf-8");
//                // 这里URLEncoder.encode可以防止中文乱码  注意这里Chrome仍然会乱码
//                String fileName = URLEncoder.encode("CV" + candidate1.getName(), "UTF-8").replaceAll("\\+", "%20");
//                //设置导出excl文件格式
//                //response.setHeader("Content-Disposition", "attachment;utf-8;filename=" + fileName + ".xlsx");
//                //设置导出word文件格式
//                response.setHeader("Content-Disposition", "attachment;utf-8;filename=" + fileName + ".docx");
//                response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");

                //todo获取表信息

                //todo获取表字段信息
                String addr = "";
                if (StringUtils.isBlank(candidate1.getArea())) {

                } else {
                    if (candidate1.getArea().trim().equals("HK")) {
                        addr = "HK  " + candidate1.getDistrict();
                    } else {
                        addr = candidate1.getArea() + "  " + candidate1.getDistrict();
                    }
                }
                String sex = "未知";
                if (StringUtils.isBlank(candidate1.getGender())) {

                } else {
                    if (candidate1.getGender().trim().equals("M")) {
                        sex = "男";
                    } else if (candidate1.getGender().trim().equals("F")){
                        sex = "女";
                    } else {
                        sex = "未知";
                    }
                }
                List<EducationData> educationDataList = new ArrayList<>();
                List<SysSchool> candidate1SchoolList = candidate1.getSchoolList();
                if (candidate1SchoolList != null && candidate1SchoolList.size() > 0) {
                    for (int k = 0; k < candidate1SchoolList.size(); k++) {
                        String startTime = StringUtils.isBlank(candidate1SchoolList.get(k).getStartTime())
                                ?
                                "unknown"
                                :
                                candidate1SchoolList.get(k).getStartTime().split(" ")[0];
                        String endTime = StringUtils.isBlank(candidate1SchoolList.get(k).getEndTime())
                                ?
                                "unknown"
                                :
                                candidate1SchoolList.get(k).getEndTime().split(" ")[0];
                        EducationData educationData = EducationData.builder()
                                .time( startTime + " to " + endTime)
                                .name(candidate1SchoolList.get(k).getName())
                                .major(candidate1SchoolList.get(k).getMajor() + "/" +
                                        candidate1SchoolList.get(k).getDegree())
                                .build();
                        educationDataList.add(educationData);
                    }

                }
                List<JobData> jobDataList = new ArrayList<>();
                List<Ccompany> candidate1CcompanyList = candidate1.getCcompanyList();
                if (candidate1CcompanyList != null && candidate1CcompanyList.size() > 0) {
                    for (int m = 0; m < candidate1CcompanyList.size(); m++) {
                        String startTime = StringUtils.isBlank(candidate1CcompanyList.get(m).getStartTime())
                                ?
                                "unknown"
                                :
                                candidate1CcompanyList.get(m).getStartTime().split(" ")[0];
                        String endTime = StringUtils.isBlank(candidate1CcompanyList.get(m).getEndTime())
                                ?
                                "unknown"
                                :
                                candidate1CcompanyList.get(m).getEndTime().split(" ")[0];
                        JobData jobData = JobData.builder()
                                .time( startTime + " to " + endTime)
                                .name(candidate1CcompanyList.get(m).getCom())
                                .position(candidate1CcompanyList.get(m).getTitle())
                                .detail(
                                        RemoveHtmlCode.
                                                removeHtmlCode(
                                                        candidate1CcompanyList.get(m).getDescription()))
                                .build();
                        jobDataList.add(jobData);
                    }
                }
                JobslinkData data = JobslinkData.builder()
                        .name(candidate1.getName())
                        .position(candidate1.getJobFunction())
                        .address(addr)
                        .age(candidate1.getAge() + "")
                        .sex(sex)
                        .salary(candidate1.getSalary() + "")
                        .educationList(educationDataList)
                        .jobList(jobDataList)
                        .build();

                //获取resources下目中录模板文件
                //File file = new ClassPathResource("xxx/xxx.docx").getFile();
                //以流的形式 获取resources下目中录模板文件
//                InputStream file = new ClassPathResource("static/Jobslink.docx").getInputStream();
//                EasyWord.of(file).doWrite(data).toOutputStream(response.getOutputStream());
                String filePath = RuoYiConfig.getDownloadPath() + "Jobslink.docx";
                File file = new File(filePath);
                FileOutputStream out = new FileOutputStream(
                        RuoYiConfig.getDownloadPath() + "CV_" + candidate1.getName() + ".docx");
                EasyWord.of(file).doWrite(data).toOutputStream(out);
                Map result = new HashMap();
                result.put("filename", "CV_" + candidate1.getName() + ".docx");
                return success(result);
            } else {
                // 重置response
                return error("下载失败");
            }
        } catch (Exception e) {
            // 重置response
            return error("下载失败");
        }
    }


    @GetMapping("/listSearch")
    public TableDataInfo listSearch(Candidate candidate)
    {
        startPage();
        List<Candidate> list = candidateService.selectCandSearchList(candidate);
        if (list != null && list.size() > 0) {
            Calendar calendar = Calendar.getInstance();
            int year = calendar.get(Calendar.YEAR);
            for (int i = 0; i < list.size(); i++) {
                //计算年龄
                if (!StringUtils.isBlank(list.get(i).getBirthyear())) {
                    int y = year - Integer.valueOf(list.get(i).getBirthyear()).intValue();
                    list.get(i).setAge(y);
                }
                //获取所有的简历，查出对应的公司
                Ccompany ccompany = new Ccompany();
                ccompany.setCid(list.get(i).getId());
                List<Ccompany> ccompanies = ccompanyService.selectCcompanyList(ccompany);
                list.get(i).setCcompanyList(ccompanies);

                SysProject sysProject = new SysProject();
                sysProject.setCid(list.get(i).getId());
                List<SysProject> sysProjectList = sysProjectService.selectSysProjectList(sysProject);
                list.get(i).setProList(sysProjectList);

                //查询学校
                SysSchool sysSchool = new SysSchool();
                sysSchool.setUserId(list.get(i).getId());
                List<SysSchool> sysSchoolList = sysSchoolService.selectSysSchoolList(sysSchool);
                list.get(i).setSchoolList(sysSchoolList);
                //查出对应的创建者和更新者
                if (list.get(i).getCreateUserid() != null) {
                    SysUser sysUser = sysUserService.selectUserById(list.get(i).getCreateUserid());
                    if (sysUser != null) {
                        list.get(i).setCreateBy(sysUser.getUserName());
                    }
                }
                if (list.get(i).getUpdateUserid() != null) {
                    SysUser sysUser = sysUserService.selectUserById(list.get(i).getUpdateUserid());
                    if (sysUser != null) {
                        list.get(i).setUpdateBy(sysUser.getUserName());
                    }
                }
                String filePath = list.get(i).getFilePath();
                //需要检查的文件格式
                for (int j = 0; j < MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION.length; j++) {
                    File file = new File("/home/ruoyi/uploadPath/folder/" + "CV" + list.get(i).getId() + "." + MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION[j]);
                    if (file.exists()) {
                        //存在
                        if (StringUtils.isBlank(filePath)) {
                            filePath = "http://jobslink.megaslink.com/profile/folder/" + "CV" + list.get(i).getId() + "." + MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION[j];
                        } else {
                            filePath = filePath + "," + "http://jobslink.megaslink.com/profile/folder/" + "CV" + list.get(i).getId() + "." + MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION[j];
                        }
                    }
                }
                list.get(i).setFilePath(filePath);
            }
        }
        return getDataTable(list);
    }

    @Resource
    private ISysProjectService sysProjectService;

    /**
     * 查询【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('system:candidate:list')")
    @GetMapping("/list")
    public TableDataInfo list(Candidate candidate)
    {
        startPage();
        Calendar calendar = Calendar.getInstance();
        int year = calendar.get(Calendar.YEAR);
        if (candidate.getMinAge() != null) {
            int maxB = year - candidate.getMinAge();
            candidate.setMaxBirthyear(maxB);
        }
        if (candidate.getMaxAge() != null) {
            int minB = year - candidate.getMaxAge();
            candidate.setMinBirthyear(minB);
        }
        List<Candidate> list =
                candidateService.selectCandidateList(candidate);
        if (list != null && list.size() > 0) {
            for (int i = 0; i < list.size(); i++) {
                //计算年龄
                if (!StringUtils.isBlank(list.get(i).getBirthyear())) {
                    int y = year - Integer.valueOf(list.get(i).getBirthyear()).intValue();
                    list.get(i).setAge(y);
                }
                if (list.get(i).getCreateUserid() != null){
                    SysUser sysUser =
                            sysUserService.selectUserById(list.get(i).getCreateUserid());
                    list.get(i).setCreateUserName(sysUser.getUserName());
                }
                //获取所有的简历，查出对应的公司
                Ccompany ccompany = new Ccompany();
                ccompany.setCid(list.get(i).getId());
                List<Ccompany> ccompanies = ccompanyService.selectCcompanyList(ccompany);
                list.get(i).setCcompanyList(ccompanies);

                //获取所有项目经历
                SysProject sysProject = new SysProject();
                sysProject.setCid(list.get(i).getId());
                List<SysProject> sysProjectList = sysProjectService.selectSysProjectList(sysProject);
                list.get(i).setProList(sysProjectList);

                //查询学校
                SysSchool sysSchool = new SysSchool();
                sysSchool.setUserId(list.get(i).getId());
                List<SysSchool> sysSchoolList = sysSchoolService.selectSysSchoolList(sysSchool);
                list.get(i).setSchoolList(sysSchoolList);
                //查出对应的创建者和更新者
                if (list.get(i).getCreateUserid() != null) {
                    SysUser sysUser = sysUserService.selectUserById(list.get(i).getCreateUserid());
                    if (sysUser != null) {
                        list.get(i).setCreateBy(sysUser.getUserName());
                    }
                }
                if (list.get(i).getUpdateUserid() != null) {
                    SysUser sysUser = sysUserService.selectUserById(list.get(i).getUpdateUserid());
                    if (sysUser != null) {
                        list.get(i).setUpdateBy(sysUser.getUserName());
                    }
                }
                String filePath = list.get(i).getFilePath();
                //需要检查的文件格式
                for (int j = 0; j < MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION.length; j++) {
                    File file = new File("/home/ruoyi/uploadPath/folder/" + "CV" + list.get(i).getId() + "." + MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION[j]);
                    if (file.exists()) {
                        //存在
                        if (StringUtils.isBlank(filePath)) {
                            filePath = "http://jobslink.megaslink.com/profile/folder/" + "CV" + list.get(i).getId() + "." + MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION[j];
                        } else {
                            filePath = filePath + "," + "http://jobslink.megaslink.com/profile/folder/" + "CV" + list.get(i).getId() + "." + MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION[j];
                        }
                    }
                }
                list.get(i).setFilePath(filePath);
            }
        }
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
//    @PreAuthorize("@ss.hasPermi('system:candidate:export')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Candidate candidate)
    {
        List<Candidate> list = candidateService.selectCandidateList(candidate);
        ExcelUtil<Candidate> util = new ExcelUtil<Candidate>(Candidate.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:candidate:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(candidateService.selectCandidateById(id));
    }

    /**
     * 新增【请填写功能名称】
     */
//    @PreAuthorize("@ss.hasPermi('system:candidate:add')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Candidate candidate)
    {
        candidate.setCreateTime(new Date());
        candidate.setCreateUserid(getUserId());
        candidate.setUpdateTime(new Date());
        candidate.setUpdateUserid(getUserId());
        //工作经历和教育经历时间处理
        List<Ccompany> ccompanyList = candidate.getCcompanyList();
        if (ccompanyList != null && ccompanyList.size() > 0) {
            for (int i = 0; i < ccompanyList.size(); i++) {
                if(!StringUtils.isBlank(ccompanyList.get(i).getStartTime()) &&
                        !ccompanyList.get(i).getStartTime().contains("00:00:00")){
                    ccompanyList.get(i).setStartTime(
                            ccompanyList.get(i).getStartTime() + "-01 00:00:00");
                }
                if(!StringUtils.isBlank(ccompanyList.get(i).getEndTime()) &&
                        !ccompanyList.get(i).getEndTime().contains("00:00:00")){
                    ccompanyList.get(i).setEndTime(
                            ccompanyList.get(i).getEndTime() + "-01 00:00:00");
                }
            }
        }
        List<SysProject> proList = candidate.getProList();
        if (proList != null && proList.size() > 0) {
            for (int m = 0; m < proList.size(); m++) {
                if (!StringUtils.isBlank(proList.get(m).getStartTime()) &&
                        !proList.get(m).getStartTime().contains("00:00:00")) {
                    proList.get(m).setStartTime(proList.get(m).getStartTime() + "-01 00:00:00");
                }
                if (!StringUtils.isBlank(proList.get(m).getEndTime()) &&
                        !proList.get(m).getEndTime().contains("00:00:00")) {
                    proList.get(m).setEndTime(proList.get(m).getEndTime() + "-01 00:00:00");
                }
            }
        }
        List<SysSchool> schoolList = candidate.getSchoolList();
        if (schoolList != null && schoolList.size() > 0) {
            for (int m = 0; m < schoolList.size(); m++) {
                if (!StringUtils.isBlank(schoolList.get(m).getStartTime()) &&
                        !schoolList.get(m).getStartTime().contains("00:00:00")) {
                    schoolList.get(m).setStartTime(schoolList.get(m).getStartTime() + "-01 00:00:00");
                }
                if (!StringUtils.isBlank(schoolList.get(m).getEndTime()) &&
                        !schoolList.get(m).getEndTime().contains("00:00:00")) {
                    schoolList.get(m).setEndTime(schoolList.get(m).getEndTime() + "-01 00:00:00");
                }
            }
        }
        long insertCandidate = candidateService.insertCandidate(candidate);
        if (insertCandidate > 0) {
            return success(candidate.getId());
        } else {
            return toAjax(-1);
        }
    }

    /**
     * 修改【请填写功能名称】
     */
//    @PreAuthorize("@ss.hasPermi('system:candidate:edit')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody Candidate candidate)
    {
        //去掉HTML标签
        if (!StringUtils.isBlank(candidate.getName())) {
            candidate.setName(StringUtils.delHTMLTag(candidate.getName()));
        }
        if (!StringUtils.isBlank(candidate.getEmail1())) {
            candidate.setEmail1(StringUtils.delHTMLTag(candidate.getEmail1()));
        }
        if (!StringUtils.isBlank(candidate.getPhone1())) {
            candidate.setPhone1(StringUtils.delHTMLTag(candidate.getPhone1()));
        }
        //工作经历和教育经历时间处理
        List<Ccompany> ccompanyList = candidate.getCcompanyList();
        if (ccompanyList != null && ccompanyList.size() > 0) {
            for (int i = 0; i < ccompanyList.size(); i++) {
                if(!StringUtils.isBlank(ccompanyList.get(i).getStartTime()) &&
                        !ccompanyList.get(i).getStartTime().contains("00:00:00")){
                    ccompanyList.get(i).setStartTime(
                            ccompanyList.get(i).getStartTime() + "-01 00:00:00");
                }
                if(!StringUtils.isBlank(ccompanyList.get(i).getEndTime()) &&
                        !ccompanyList.get(i).getEndTime().contains("00:00:00")){
                    ccompanyList.get(i).setEndTime(
                            ccompanyList.get(i).getEndTime() + "-01 00:00:00");
                }
            }
        }

        List<SysProject> proList = candidate.getProList();
        if (proList != null && proList.size() > 0) {
            for (int i = 0; i < proList.size(); i++) {
                if(!StringUtils.isBlank(proList.get(i).getStartTime()) &&
                        !proList.get(i).getStartTime().contains("00:00:00")){
                    proList.get(i).setStartTime(
                            proList.get(i).getStartTime() + "-01 00:00:00");
                }
                if(!StringUtils.isBlank(proList.get(i).getEndTime()) &&
                        !proList.get(i).getEndTime().contains("00:00:00")){
                    proList.get(i).setEndTime(
                            proList.get(i).getEndTime() + "-01 00:00:00");
                }
            }
        }

        List<SysSchool> schoolList = candidate.getSchoolList();
        if (schoolList != null && schoolList.size() > 0) {
            for (int m = 0; m < schoolList.size(); m++) {
                if (!StringUtils.isBlank(schoolList.get(m).getStartTime()) &&
                        !schoolList.get(m).getStartTime().contains("00:00:00")) {
                    schoolList.get(m).setStartTime(schoolList.get(m).getStartTime() + "-01 00:00:00");
                }
                if (!StringUtils.isBlank(schoolList.get(m).getEndTime()) &&
                        !schoolList.get(m).getEndTime().contains("00:00:00")) {
                    schoolList.get(m).setEndTime(schoolList.get(m).getEndTime() + "-01 00:00:00");
                }
            }
        }
        return toAjax(candidateService.updateCandidate(candidate));
    }

    /**
     * 删除【请填写功能名称】
     */
//    @PreAuthorize("@ss.hasPermi('system:candidate:remove')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(candidateService.deleteCandidateByIds(ids));
    }
}
